<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2024/4/23
 * Time: 14:20
 */

namespace app\controller\index\user;


use app\controller\index\BaseController;
use app\exception\IndexException;
use app\logic\index\user\PlatformAccountLogic;
use support\Request;
use support\Response;

class PlatformAccountController extends BaseController
{
    public function getList(Request $request):Response
    {
        $param = [];
        $data = PlatformAccountLogic::getInstance()->getList($param);
        return $this->endSuccess($data);
    }

    public function submitAccount(Request $request):Response
    {
        $param = [];
        $param['platform_id'] = $request->input('platform_id');
        $param['nickname'] = $request->input('nickname');
        $param['account_id'] = $request->input('account_id');
        if(empty($param['platform_id'])){
            throw new IndexException(4020,'请选择平台');
        }
        if(empty($param['nickname'])){
            throw new IndexException(4020,'昵称必填');
        }
        if(empty($param['account_id'])){
            throw new IndexException(4020,'账号ID必填');
        }
        $data = PlatformAccountLogic::getInstance()->submitAccount($param);
        return $this->endSuccess($data);
    }
}